/**
 * @class
 * @memberof w.parser
 * @param {*} message 消息
 * @param {*} callback 处理完成的回调
 */
function createCircle(message, callback) {
  let { section, radius } = message;
  let position = new Float32Array(3 * (section + 1));
  let indices = new Uint16Array(3 * section);
  let radPer = 2 * Math.PI / section;
  position.set([0, 0, 0]);
  for (let i = 0; i < section; i++) {
    let rad = radPer * i;
    let x = radius * Math.cos(rad);
    let y = radius * Math.sin(rad);
    position.set([x, y, 0], (i + 1) * 3);
    if (i < section - 1) {
      indices.set([0, i + 1, i + 2], i * 3);
    } else {
      indices.set([0, i + 1, 1], i * 3);
    }
  }
  callback({ data: { indices, position }, transferlist: [indices.buffer, position.buffer] });
}

export { createCircle }